<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../common/meta.jsp"%>


		<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

.tc_box {
	width: 400px;
	height: 200px;
	border: 2px solid red;
	position: absolute;
	z-index: 2000;
	background: #FFC;
	display: none;
}

.sp_box {
	width: 100%;
	position: absolute;
	z-index: 1000;
	background: #000;
	top: 0;
	left: 0;
	display: none;
}
</style>

		<style>
.main .formdiv {
	width: 400px;
}
</style>
		<script type="text/javascript">
jQuery.validator.addMethod("loginname", function(value, element) {   
    var tel = /^[a-zA-Z][a-zA-Z0-9_]{4,16}$/;
    return this.optional(element) || (tel.test(value));
}, "");

jQuery.validator.addMethod("phonenumber", function(value, element) {   
    var tel = /^(13[0-9]|15[0|3|6|7|8|9]|18[3|6|7|8|9])\d{8}$/;
    return this.optional(element) || (tel.test(value));
}, "");
$(function() {
	
	$("#clear").click(function(){
		$(".inputbox").val("");
	});
	var updateForm=$("#updateCustomerForm").validate( {
	 
		rules : {
			customerName : {
				required : true
			},
			customerAddr : {
				required : true
			},
			customerPhone : {
				required : true
			},
			contract : {
				required : true
			},
			 
			mobile : {
				required :true,
				phonenumber : true
			}

		},
		messages : {
			customerName : {
				required : "必填"
			},
			customerAddr : {
				
					required : "必填"
			},
			customerPhone : {
				required : "必填"
			},
			contract : {
				required : "必填"
			}, 
			mobile : {
				required : "必填"
			},mobile : {
				phonenumber : "手机号码输入不正确"
			},
			focusInvalid : false,
			onkeyup : false
		//获得焦点时不验证
		}
	});

	$("#submit").click(function(){
			if(updateForm.form())
			{
			 $("#updateCustomerForm").ajaxSubmit(function(result) {
			 var json =  eval(result);
					var msg=json.msg;
					 
					if (json.result) {
						if(json.flag==true)
						{
					 	art.dialog( {
					icon : 'success',
					lock : true,
					resize : false,
					title : "修改成功",
					content : msg,
					ok: function(){
						location.href='${path}/customer/manage/index/getcustomers';
					}
						})
						
						}else
						{
							art.dialog( {
					icon : 'error',
					lock : true,
					resize : false,
					title : "修改失败",
					content : msg
					});
						}
					} else {
						alert(msg);
					}
			 
				});
				 
				}
				});
});
</script>
	</head>



	<body id="master">

		<sfa:mainHeader></sfa:mainHeader>
		 <!--右边-->
            <div class="webpart3 contentarea">
                <div class="webpart-head">
                    <div class="webpart-head-item">
                      编辑客户<font color="red"><c:out value="${update}"></c:out> </font>
                        <div class="tools-btn">
                             
                            &nbsp;&nbsp;<a href="javascript:" onclick="javascript:history.go(-1);"><span>
                                <img src="${path}/statics/images/Redo.gif" style="margin-right: 4px; margin-bottom: -3px;" />返回</span></a></div>
                    </div>
                </div>
                <div class="webpart-main">
                    <div class="webpart-main-item" style="padding-top: 12px;">
                        <div class="search">
                            <!----------- 查询信息 ------------------>
                            <form id="updateCustomerForm"
					action="${path}/customer/manage/index/update"
					method="post">
					<input type="hidden" id="saleCustomerId" name="saleCustomerId" value="${customer.saleCustomerId}">
                            <table cellpadding="0" cellspacing="0" >
							<tr><th colspan="6"><font color="red">(后面带*为必填项)</font></th></tr>
                                <tr >
                                    <th style="vertical-align: top;">
                                        修改人：
                                    </th>
                                    <td>
                                        ${user.userName}(${user.loginName})
                                    </td>
                            </tr>
                            <tr>  
                                    <th style="vertical-align: top;">
                                       客户姓名:
                                    </th>
                                    <td>
                                        <input type="text" class="input-txt" id="customerName"  
										name="customerName"  value="${customer.customerName }"/>
										<font color='red'>*</font>
									 
                                    </td>
                                    
                                </tr>
                                 <tr>   
                                    <th>
                                     客户地址:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerAddr"  
										name="customerAddr"  value="${customer.customerAddr }"/>
										<font color='red'>*</font>
                                    </td>
                                    
                                </tr>
                                <tr>   
                                    <th>
                                     邮编:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerCode"  
										name="customerCode"  value="${customer.customerCode }"/>
                                    </td>
                                    
                                </tr>
                                <tr>   
                                    <th>
                                     客户电话:
                                     </th>
                                     <td>
                                        <input type="text" class="input-txt" id="customerPhone"  
										name="customerPhone"  value="${customer.customerPhone }"/>
										<font color='red'>*</font>
                                    </td>
                                    
                                </tr>
                                
                                <tr>
                                	<th style="vertical-align: top;">
                                       客户类型:
                                	</th>
                                	<td>
                                		<sfa:dic showType="select" kindNo="CUSTOMERTYPE"
										 attr="class='input-txt' style='width:130px'"  code="${customer.customerType }"
										name="customerType" id="customerType">
									</sfa:dic>
                                	</td>
                                	 
                                	 
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                        联系人:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="contract"  
										name="contract" value="${customer.contract }"/>
										   <font color="red" class="contract"> </font>
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                       职位:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="position"  
										name="position" value="${customer.position }"/>
                                    </td>
                                </tr>
                                
                                <tr>
                                
                                 <th style="vertical-align: top;">
                                        手机号码:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="mobile"  
										name="mobile" value="${customer.mobile }"/>
										   <font color="red" class="mobile"> </font>
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                       QQ:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="QQ"  
										name="QQ" value="${customer.QQ }"/>
                                    </td>
                                </tr>
                                <tr>
                                
                                 <th style="vertical-align: top;">
                       email:
                                    </th>
                                    <td colspan="2">
                                        <input type="text" class="input-txt" id="email"  
										name="email" value="${customer.email }"/>
                                    </td>
                                </tr>
                                
                                
                                
                                
                                <tr>
                                	<td align="center" colspan="9">
                                	 <input name="submit" type="button" id="submit" tabindex="5"
										class="linkbtn2" value="提交">
									<input name="clear" type="reset" id="clear" tabindex="5"
										class="linkbtn2" value="清空">
                                	</td>
                                </tr>
                                 
                            </table>
                            </form>
                        </div>
                   </div>
                   </div>
                   
                   <div class="webpart-foot">
                    <div class="webpart-foot-item">
                    </div>
                </div>
            </div>
            
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>


